//
//  BLMeet_Cell_Index.m
//  Byelone
//
//  Created by 乔小乔 on 2020/12/16.
//

#import "BLMeet_Cell_Index.h"

@implementation BLMeet_Cell_Index

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.viewBj.layer.cornerRadius = 6;
    self.viewBj.layer.borderColor = [UIColor chColorWithHexString:@"#080604" alpha:0.07].CGColor;
    self.viewBj.layer.borderWidth = 1;
    [self.viewBj setShadowRadius:3 color:BL_COLOR_PURPLE_L(0.12) offset:CGSizeMake(0, 0) opacity:1];
    self.imgHeadPic.layer.cornerRadius = 20;
    self.imgHeadPic.layer.masksToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)reloadWithData:(BLMeetItem *)model{
    [self.imgHeadPic sd_setImageWithURL:[NSURL URLWithString:model.userHomeBaseVo.picture?:@""] placeholderImage:nil];
    self.labelName.text = model.userHomeBaseVo.nickname;
    self.labelDesc.text = [NSString stringWithFormat:@"%@cm | %@kg",model.userHomeBaseVo.height,model.userHomeBaseVo.weight];
    [self.imgContent sd_setImageWithURL:[NSURL URLWithString:model.photoPath?:@""] placeholderImage:nil options:SDWebImageProgressiveLoad];
    [self.viewDescs.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    NSMutableArray *arrayDesc = [NSMutableArray arrayWithArray:@[@{@"title":model.userHomeBaseVo.age?:@"",@"img":[UIImage imageNamed:model.userHomeBaseVo.gender.intValue==1?@"common_boy":@"common_girl"],@"color":model.userHomeBaseVo.gender.intValue==1?@"#6891F7":@"#FD5680"},@{@"title":[NSString stringWithFormat:@"%@-%@",model.userHomeBaseVo.homeAreaName,model.userHomeBaseVo.homeCityName],@"img":[UIImage imageNamed:@"common_location"],@"color":@"#56BDFF"}]];
    if (![NSString blIsBlankString:model.yearIncomeName]) {
        [arrayDesc addObject:@{@"title":@"30-40w",@"img":[UIImage imageNamed:@"common_money"],@"color":@"#6C72F5"}];
    }
    
    CGFloat descLeft = 0;
    for (int i=0; i<arrayDesc.count; i++) {
        NSDictionary *dict = arrayDesc[i];
        UIView *view = [BLCommonTool createTip:dict[@"img"] title:dict[@"title"] color:[UIColor chColorWithHexString:dict[@"color"]] point:CGPointMake(descLeft, 0)];
        [self.viewDescs addSubview:view];
        descLeft = descLeft + view.frame.size.width+6;
    }
    
    [self.viewTips.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    NSMutableArray *arrayTip = [NSMutableArray new];
    if (model.highCredit) {
        [arrayTip addObject:@{@"title":@"高信用",@"img":[UIImage imageNamed:@"meet_credit"],@"color":@"#56BDFF"}];
    }
    if (model.active) {
        [arrayTip addObject:@{@"title":@"高活跃",@"img":[UIImage imageNamed:@"meet_active"],@"color":@"#6C72F5"}];
    }
    if (model.highCharm) {
        [arrayTip addObject:@{@"title":@"高魅力",@"img":[UIImage imageNamed:@"meet_charm"],@"color":@"#FD5680"}];
    }
    
    CGFloat tipLeft = 0;
    for (int i=0; i<arrayTip.count; i++) {
        NSDictionary *dict = arrayTip[i];
        UIView *view = [BLCommonTool createDesc:dict[@"img"] title:dict[@"title"] color:[UIColor chColorWithHexString:dict[@"color"]] point:CGPointMake(tipLeft, 0)];
        [self.viewTips addSubview:view];
        tipLeft = tipLeft + view.frame.size.width+6;
    }
}
- (IBAction)clickAction:(UIButton *)sender {
    if (self.myBlock) {
        self.myBlock(sender.tag);
    }
    
    if (sender.tag==101) {
        sender.selected = !sender.selected;
    }
}
@end
